package logic

import (
	"api/model/mysql"
	"context"
	"srv/dev"
	"srv/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type InfoLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InfoLogic {
	return &InfoLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *InfoLogic) Info(in *dev.InfoRequest) (*dev.InfoResponse, error) {
	// todo: add your logic here and delete this line

	var house mysql.Houses

	mysql.DB.Where("id=?", in.Id).Find(&house)

	return &dev.InfoResponse{
		Name:    house.Name,
		Address: house.Address,
		Typed:   house.Typed,
		Area:    int64(house.Area),
		Floor:   int64(house.Floor),
		Price:   float32(house.Price),
		Id:      int64(house.ID),
	}, nil
}
